import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.rms.RecordStore;

public class Profiles extends Canvas{
	private Display display;
	private MainMenu mainmenu;
	//private RecordStore rs;
	private String srfr, srfr2,er;
	public static final String PLAYER_NAME = "player_name";
	private byte[] batw;
	private int len;
	private boolean err;
	public Profiles(GameMIDlet midlet, Display display){		
		this.display = display;
		mainmenu = new MainMenu(midlet, display);
		err = false;
		er = "";		
		len = 0;	
		srfr = "MRD";		
		//writeRecord();	
		setFullScreenMode(true);
	}	
	protected void paint(Graphics g){
		g.setColor(255, 255, 255);		
		g.fillRect(0, 0, 128, 160);
		//g.drawLine(64,0,64,160);
		g.setColor(255, 100, 250);
		if(Option.language  == true){
			//dong duoi dung de ve dong mau sang,			
			g.fillRect(20, 24, 88, 15);					
			//con 2 dong tiep theo chi ve nhung mui ten don gian, chon cach nao cung duoc
			//g.drawString(">>>", 19, 25, 0);
			//g.drawString("<<<", 90, 25, 0);
			g.setColor(0, 0, 0);
			//g.drawLine(64,0,64,160);
			g.drawString("Chon Nguoi Cau Ca:", 17, 5, 0);	
			g.drawString("Mr.D",52,25,0);
			g.drawString("Them Nguoi Moi",25,40,0);
			g.drawString("Them Nguoi Moi",25,55,0);
			g.drawString("Them Nguoi Moi",25,70,0);
			g.drawString("Them Nguoi Moi",25,85,0);
		}
		else{
			//dong duoi dung de ve dong mau sang,			
			g.fillRect(20, 24, 88, 15);
			//con 2 dong tiep theo chi ve nhung mui ten don gian, chon cach nao cung duoc
			//g.drawString(">>>", 25, 40, 0);
			//g.drawString("<<<", 83, 40, 0);
			g.setColor(0, 0, 0);	
			//g.drawLine(64,0,64,160);		
			g.drawString("Select Fisher:", 32, 5, 0);
			g.drawString("Mr.D",52,25,0);
			//g.drawString(srfr2,36,40,0);
			g.drawString("New Fisher",36,40,0);
			g.drawString("New Fisher",36,55,0);
			g.drawString("New Fisher",36,70,0);
			g.drawString("New Fisher",36,85,0);
		}
		if(err == true){
			g.setColor(255,255,255);
			g.fillRect(0,0,128,160);
			g.setColor(0,0,0);
			g.drawString(er,-90,5,0);			
		}
	}
	protected void keyPressed(int code){
		//Xu ly hien thi khi chon ngon ngu
		if((code == 53)||(code == -5)){				
			//Sau khi chon ngon ngu la load goi ngon ngu
			display.setCurrent(mainmenu);			
		}
		//Xu ly hien thi khi nhan len
		if((code == 50)||(code == -1)){
			if(Option.language == true)
				Option.language = false;
			else{
				//writeRecord();	
				Option.language = true;
			}
		}
		//Xu ly hien thi khi nhan xuong
		if((code == 56)||(code == -2)){
			if(Option.language == true)
				Option.language = false;
			else{
				//readRecord();
				Option.language = true;				
			}
		}
		repaint();
	}
	public static void writeRecord(){
		try{
			String srfr1 = "MrDMGDD";	
			//byte[] batw1 = srfr1.getBytes();			
			//RecordStore rs = RecordStore.openRecordStore(PLAYER_NAME, true);
			//rs.addRecord(batw1, 0, batw1.length);
			//rs.closeRecordStore();
		}
		catch(Exception e){
			//err = true;
			//er = e.toString();
		}
	}	
	public static void readRecord(){
		try{
			RecordStore rs = RecordStore.openRecordStore(PLAYER_NAME, false);
			//byte[] batw2 = new byte[10];
			//int len1 = rs.getRecord(1,batw2, 0);
			//srfr2 = new String(batw2, 0, len1);
			//rs.closeRecordStore();
		}
		catch(Exception e){//err = true;er = e.toString();
		}
	}
}